package me.itsoo.artemis.framework.core.collect;

import java.util.Iterator;

/**
 * EmptyKvs
 *
 * @author zxy
 * @version 0.0.1
 * @since 2023/6/1
 */
public class EmptyKvs extends Kvs<Object, Object> {

    private static final long serialVersionUID = 1820431008583728429L;

    @Override
    public void add(Kv<Object, Object> kv) {
        // NOP
    }

    @Override
    public void addAll(Kvs<Object, Object> kvs) {
        // NOP
    }

    @Override
    public int size() {
        return 0;
    }

    @Override
    public boolean isEmpty() {
        return true;
    }

    @Override
    public Iterator<Kv<Object, Object>> iterator() {
        return createItr();
    }

    /**
     * 创建迭代器
     *
     * @return Itr
     */
    private Itr createItr() {
        return new Itr() {
            @Override
            public boolean hasNext() {
                return false;
            }

            @Override
            public Kv<Object, Object> next() {
                return null;
            }
        };
    }
}
